package model;

import observer.Subject;

public class VendingMachineModel extends Subject{

  private final int drinkPrice = 100;
  private int balance;

  public VendingMachineModel() {
    balance = 0;
  }

  private void insertBalance(int value){
    balance += value;
    this.notifyObserver();
    
  }
  
  private void substractBalance(int value){
    balance -= value;
    this.notifyObserver();
  }

  
  private void setBalance(int value){
    balance = value;
    this.notifyObserver();
    
  }

  private int getBalance(){
    return balance;
  }

  
  public void insertCoin(int input){
    insertBalance( input );
  }

  public int getCoin(){
    return getBalance();
  }

  public void clearCoin(){
    setBalance(0);
  }
  
  public int getDrinkPrice(){ 
    return drinkPrice;
  }
  
  public void buyDrink(){
    substractBalance(getDrinkPrice());
  }
}